//
//  DJOANetWorkRequest.m
//  AFNetworking
//
//  Created by 陈樟权 on 2020/6/1.
//

#import "DJOANetWorkRequest.h"
#import "DJOANetWorkManager.h"
@implementation DJOANetWorkRequest

-(instancetype)init{
    if (self = [super init]){
        _requestMethod = DJOANetWorkRequestMethodGET;
        _requestSerializerType = DJOANetWorkRequestSerializerTypeHTTP;
        _responseSerializerType = DJOANetWorkResponseSerializerTypeJSON;
        _reqeustTimeoutInterval = 30;
        _enableLog = YES;
    }
    return self;
}


-(void)startWithCompletionBlockWithSuccess:(nullable DJOANetWorkRequestCompletionBlock)success failure:(nullable DJOANetWorkRequestCompletionBlock)failure{
    self.successCompletionBlock = success;
    self.failureCompletionBlock = failure;
    [self start];
}

-(void)start{
    [[DJOANetWorkManager manager] sendRequest:self];
}

-(NSString *)description{
    NSString *requestMethod = @"";
    switch (self.requestMethod) {
        case DJOANetWorkRequestMethodGET:
            requestMethod = @"GET";
            break;
        case DJOANetWorkRequestMethodPOST:
            requestMethod = @"POST";
            break;
        default:
            break;
    }
    return [NSString stringWithFormat:@"<%@: %p>{ URL: %@ } { method: %@ } { header: %@} { arguments: %@ }", NSStringFromClass([self class]), self, self.baseUrl, requestMethod, self.header, self.param];
}

@end
